package xx.pro.consumer.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import static xx.pro.common.constans.Constants.MAN_QUEUE;
import static xx.pro.common.constans.Constants.WO_MAN_QUEUE;

@Slf4j
@Component
public class TopicConsumer {

    /**
     * 主题交换机-消费者 topic.man
     *
     * @param message
     */
    @RabbitListener(queues = MAN_QUEUE)
    public void topicManConsumer(Message message) {
        String msg = new String(message.getBody());
        System.out.println("topicMan Consumer 消费者收到消息  : " + msg);
    }

    /**
     * 主题交换机-消费者 topic.woman
     *
     * @param message
     */
    @RabbitListener(queues = WO_MAN_QUEUE)
    public void topicWoManConsumer(Message message) {
        String msg = new String(message.getBody());
        System.out.println("topicWoMan Consumer 消费者收到消息  : " + msg);
    }
}
